using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BookingDB.Models.Mapping
{
    public class BookingMap : EntityTypeConfiguration<EntityBooking>
    {
        public BookingMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            // Table & Column Mappings
            this.ToTable("Booking");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.totalPrice).HasColumnName("totalPrice");
            this.Property(t => t.employee_Id).HasColumnName("employee_Id");
            this.Property(t => t.isCollected).HasColumnName("isCollected");
            this.Property(t => t.customer_id).HasColumnName("customer_id");

            // Relationships
            this.HasOptional(t => t.Customer)
                .WithMany(t => t.Bookings)
                .HasForeignKey(d => d.customer_id);
            this.HasOptional(t => t.Employee)
                .WithMany(t => t.Bookings)
                .HasForeignKey(d => d.employee_Id);

        }
    }
}
